import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';


class WidgetLayoutDemo extends StatefulWidget {
	WidgetLayoutDemo({Key key}) : super(key: key);

	@override
	_WidgetLayoutDemoState createState() => _WidgetLayoutDemoState();
}

class _WidgetLayoutDemoState extends State<WidgetLayoutDemo> {
	// Default value for toggle
	bool toggle = true;

	void _toggle() {
		setState(() {
			toggle = !toggle;
		});
	}

	_getToggleChild() {
		if (toggle) {
			return Text('Toggle One');
		} else {
			return CupertinoButton(
				onPressed: () {},
				child: Text('Toggle Two'),
				color: Colors.yellow,
				pressedOpacity: 0.5,
				padding: EdgeInsets.all(20),
			);
		}
	}

	@override
	Widget build(BuildContext context) {
		return Scaffold(
			appBar: AppBar(
				title: Text("Sample App"),
			),
			body: Center(
				child: Column(
					children: <Widget>[
						_getToggleChild(),
						_buttonWithInsets(),

					],
				),
			),
			floatingActionButton: FloatingActionButton(
				onPressed: _toggle,
				tooltip: 'Update Text',
				child: Icon(Icons.update),
			),
		);
    }

	Widget _buttonWithInsets() {
		return Row(
			children: <Widget>[
				CupertinoButton(
					child: Text("Insets 20"),
					color: Colors.blue,
					padding: EdgeInsets.all(20),
					onPressed: () {
						print("Button Pressed");
					}
				),
				CupertinoButton(
					child: Text("Left Insets 20"),
					color: Colors.blue,
					padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
					onPressed: () {
						print("Button Pressed");
					}
				),
				CupertinoButton(
					child: Text("Top Insets 20"),
					color: Colors.blue,
					padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
					onPressed: () {
						print("Button Pressed");
					}
				),
			],
		);
    }
}
